package com.wyzz.hr.pojo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.wyzz.hr.pojo.base.BaseAttendshift;

public class Attendshift extends BaseAttendshift implements Cloneable {

	public Attendshift() {
		newAttdNightShift = Integer.valueOf(0);
	}

	public Attendshift(String id) {
		super(id);
		newAttdNightShift = Integer.valueOf(0);
	}

	public Attendshift(String id, String attsShortName) {
		newAttdNightShift = Integer.valueOf(0);
		setId(id);
		setAttsShortName(attsShortName);
	}

	public Attendshift(String id, String attsName, Integer attsNightShift,
			String attsColor, Integer attsSortId) {
		super(id, attsName, attsNightShift, attsColor, attsSortId);
		newAttdNightShift = Integer.valueOf(0);
	}

	public String getOffDutyTime() {
		Date date = new Date();
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		String cut[] = getAttsSession().split(",");
		String offDutyTime = cut[cut.length - 1].split("-")[1];
		Date off = null;
		try {
			off = (Date) format.parseObject((new StringBuilder()).append(
					format.format(date).substring(0, 10)).append(" ").append(
					offDutyTime).toString());
			offDutyTime = format.format(off).substring(11);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return offDutyTime;
	}

	public void setOffDutyTime(String offDutyTime) {
		this.offDutyTime = offDutyTime;
	}

	public String getOnDutyTime() {
		Date date = new Date();
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		String cut[] = getAttsSession().split(",");
		String onDutyTime = cut[0].split("-")[0];
		Date on = null;
		try {
			on = (Date) format.parseObject((new StringBuilder()).append(
					format.format(date).substring(0, 10)).append(" ").append(
					onDutyTime).toString());
			onDutyTime = format.format(on).substring(11);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return onDutyTime;
	}

	public void setOnDutyTime(String onDutyTime) {
		this.onDutyTime = onDutyTime;
	}

	public String getFlag() {
		return flag;
	}

	public void setFlag(String flag) {
		this.flag = flag;
	}

	public String getNewAttdSession() {
		return newAttdSession;
	}

	public void setNewAttdSession(String newAttdSession) {
		this.newAttdSession = newAttdSession;
	}

	public List getNewAttdSessionList() {
		return newAttdSessionList;
	}

	public void setNewAttdSessionList(List newAttdSessionList) {
		this.newAttdSessionList = newAttdSessionList;
	}

	public String getDeptIdString() {
		return deptIdString;
	}

	public void setDeptIdString(String deptIdString) {
		this.deptIdString = deptIdString;
	}

	public String getLocIdString() {
		return locIdString;
	}

	public void setLocIdString(String locIdString) {
		this.locIdString = locIdString;
	}

	public Integer getNewAttdNightShift() {
		return newAttdNightShift;
	}

	public void setNewAttdNightShift(Integer newAttdNightShift) {
		this.newAttdNightShift = newAttdNightShift;
	}

	public Attendshift clo() {
		Object obj = null;
		try {
			obj = super.clone();
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return (Attendshift) obj;
	}

	public Object clone() throws CloneNotSupportedException {
		return clo();
	}

	private static final long serialVersionUID = 1L;
	private String flag;
	private String onDutyTime;
	private String offDutyTime;
	private List newAttdSessionList;
	private String newAttdSession;
	private Integer newAttdNightShift;
	private String locIdString;
	private String deptIdString;
}
